<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 边界符 ^ $
        var rg = /abc/;// 正则表达式里面不需要加引号 不管是数字型还是字符串型
        //  /abc/ 只要包含有abc这个字符串返回的都是true
        console.log(rg.test('abc'));// true
        console.log(rg.test('abcd'));//true
        console.log(rg.test('aabcd'));//true
        console.log('-------------------');
        var reg = /^abc/;
        console.log(reg.test('abc'));//true
        console.log(reg.test('abcd'));//true
        console.log(reg.test('aabcd'));//false
        console.log('-------------------');
        var reg1 = /^abc$/;//精确匹配 要求必须是abc字符串才符合规范
        console.log(reg1.test('abc'));//true
        console.log(reg1.test('abcd'));//false
        console.log(reg1.test('aabcd'));//false
        console.log(reg1.test('abcdefgabc'));;//false
    </script>
</body>

</html>